//
//  BaseTextfiled.m
//  JF_New_DYKT
//
//  Created by 陈雷 on 2017/8/24.
//  Copyright © 2017年 陈雷. All rights reserved.
//

#import "BaseTextfiled.h"

@implementation BaseTextfiled

- (instancetype)init{
    if (self = [super init]) {
        [self baseConfig];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self baseConfig];
    }
    return self;
}


- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        [self baseConfig];
        
    }
    return self;
}

- (void)baseConfig{
    
    self.inputAccessoryView = [self addToolbar];
        self.tintColor= [UIColor colorWithHexString:@"1cda9f"];
}

- (UIToolbar *)addToolbar
{
    UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, KSCreenWidth, 35)];
    toolbar.tintColor = [UIColor blueColor];
    toolbar.backgroundColor = [UIColor grayColor];
    UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(hiddenKeyboard)];
    toolbar.items = @[ space, bar];
    bar.tintColor = [UIColor colorWithHexString:@"1cda9f"];
    return toolbar;
}

#pragma mark- 回收键盘
- (void)hiddenKeyboard{
    [self resignFirstResponder];
}

@end
